<?php
//图片缩放、加水印
//这里只做了处理jpg格式,为了能兼容处理更多格式的图片应该做出相应的判断(类似判断详见vttftext)
session_start();
//$filename=$_SESSION['$dizhi'];
$filename = "../../public/imgs/1.jpg";
$img= getimagesize($filename);
list($width,$height) = $img;
$new_width = $width/2;
$new_height = $height/2;
header("content-type:image/jpeg");
$image = imagecreatefromjpeg($filename);
$newimg= imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($newimg, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);//缩放
$color = imagecolorallocate($image, 255, 255, 255);
imagettftext($newimg, 16, 10, $new_width-16*6, $new_height-14, $color, "C:/Windows/Fonts/simhei.ttf", "版权声明");//加水印
imagejpeg($newimg);//输出图片
//imagejpeg($newimg,mt_rand(10000, 99999).".jpg");//保存处理后的图片


